package ast.table

import ast.SqlNode
import ast.expr.SqlExpr
import ast.statement.select.SqlSelectQuery

sealed class SqlTableSource(
    open var alias: String? = null,
    open val columnAliasNames: MutableList<String> = mutableListOf()
) : SqlNode

data class SqlIdentifierTableSource(
    val tableName: String,
    override var alias: String? = null,
    override val columnAliasNames: MutableList<String> = mutableListOf()
) : SqlTableSource(alias)

data class SqlSubQueryTableSource(
    val select: SqlSelectQuery,
    override var alias: String? = null,
    override val columnAliasNames: MutableList<String> = mutableListOf(),
    var isLateral: Boolean = false
) :
    SqlTableSource(alias)

data class SqlJoinTableSource(
    val left: SqlTableSource,
    val joinType: SqlJoinType,
    val right: SqlTableSource,
    var on: SqlExpr? = null,
    override var alias: String? = null,
    override val columnAliasNames: MutableList<String> = mutableListOf()
) :
    SqlTableSource(alias)